package com.findviewbydream.evil.helloyouth.Welcome;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.findviewbydream.evil.helloyouth.MainActivity;
import com.findviewbydream.evil.helloyouth.R;
import com.findviewbydream.evil.helloyouth.Utils.Utils;

/********************************************
 * 工程名：HelloYouth
 * 包名：com.findviewbydream.evil.helloyouth.Welcome
 * 时间：16-6-1 下午1:35
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class Welcome extends AppCompatActivity
{
    private ImageView topImg;
    private ImageView welcomeImg;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // 隐藏标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // 隐藏状态栏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.welcome);

        initView();/*初始化控件*/
        initIMG();/*初始化图片*/

        intent();/*控制跳转*/
    }

    /**
     * 初始化控件
     */
    private void initView()
    {
        topImg = (ImageView) findViewById(R.id.topImg);
        welcomeImg = (ImageView) findViewById(R.id.welcomeImg);
    }

    /**
     * 初始化图片
     */
    private void initIMG()
    {
        //Glide.with(this).load(R.drawable.loading).centerCrop().into(topImg);
        Glide.with(this).load("http://pic2.16pic.com/00/11/47/16pic_1147240_b.jpg").into(welcomeImg);
    }

    private void intent()
    {
        new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                Utils.sleep(3000);
                handler.sendEmptyMessage(0);
            }
        }).start();
    }

    private Handler handler = new Handler()
    {
        @Override
        public void handleMessage(Message msg)
        {
            super.handleMessage(msg);
            startActivity(new Intent(Welcome.this, MainActivity.class));
            finish();
        }
    };

}
